package yf.mall.controller.api;

import com.yf.annotation.IgnoreAuth;

import com.yf.annotation.LoginUserId;
import com.yf.response.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import yf.mall.service.MyService;
import yf.mall.vo.AccountMyProfitVO;
import yf.mall.vo.MallOrderVo;
import yf.mall.vo.OrderMyInfo;

import java.util.List;

/**
 * @author xiaolongtongxie
 * @version 1.0
 * @date 2020/6/11 18:10
 */
@RequestMapping("/api/my")
@RestController
public class ApiMyController {

    @Autowired
    private MyService myService;

    /**
     * Long
     * 代收款接口
     *
     * @param userId
     * @param orderStatus
     * @param payStatus
     * @param page
     * @param limit
     * @return
     */
    @RequestMapping("myOrderList")
    public R orderList(@LoginUserId Long userId, @RequestParam Integer orderStatus, @RequestParam(name = "payStatus") Integer payStatus, int page, int limit) {
        List<MallOrderVo> orderVos = this.myService.myOrderList(userId, orderStatus, payStatus, page, limit);
        return R.ok(orderVos);
    }

    @RequestMapping("myOrderInfo")
    public R myOrderInfo(@LoginUserId Long userId) {
        OrderMyInfo orderMyInfo = this.myService.findOrderStatus(userId);
        return R.ok(orderMyInfo);
    }

    /** que
     * 我的利润
     * @param userId
     * @return
     */
    @RequestMapping("/myProfits")
    public R myProfits(@LoginUserId Long userId){
        AccountMyProfitVO myProfit = myService.findByUserIdAndBus(userId);
        return R.ok(myProfit);
    }
}
